home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C19 / stringConvTest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  757 b   |  27 lines

  1. //: C19:stringConvTest.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include "stringConv.h"
  7. #include <iostream>
  8. #include <complex>
  9. using namespace std;
  10.  
  11. int main() {
  12.   int i = 1234;
  13.   cout << "i == \"" << toString(i) << "\"\n";
  14.   float x = 567.89;
  15.   cout << "x == \"" << toString(x) << "\"\n";
  16.   complex<float> c(1.0, 2.0);
  17.   cout << "c == \"" << toString(c) << "\"\n";
  18.   cout << endl;
  19.   
  20.   i = fromString<int>(string("1234"));
  21.   cout << "i == " << i << endl;
  22.   x = fromString<float>(string("567.89"));
  23.   cout << "x == " << x << endl;
  24.   c = fromString< complex<float> >(string("(1.0,2.0)"));
  25.   cout << "c == " << c << endl;
  26. } ///:~
  27.